<template>
	<view class="petItem">
		<uni-card @click="onClick">
			<view class="head" @click="jumpToDetail">
				<!-- 头部左右布局，左边显示头像、名称、品种 -->
				<view class="left">
					<u-avatar
						:src="item.avatar_file.url"
						shape="square"
						size="80"
						class="petImg"
					></u-avatar>
					<view class="baseMsg">
						<view class="firstLine">
							<view class="name">{{item.name}}</view>
							<view class="sex">
								<u-icon v-if="item.sex == 1" name="man" color="#3c9cff" size="22" bold/>
								<u-icon v-else name="woman" color="#f56c6c" size="22" bold/>
							</view>
							<view class="age">
								 <u-badge
									type="warning"
									:value="item.calculateMonthAge"
									shape="horn"
									class="petAge"
								></u-badge>
							</view>
						</view>
						<view class="kind">
							<u-tag :text="item.petKind" plain></u-tag>
							<u-tag :text="item.constellation + '座'" plain style="margin-left: 10rpx;"></u-tag>
						</view>
					</view>
				</view>
				<view class="right">
					<!-- 写一个右箭头，能跳转到详情页 -->
					<u-icon name="arrow-right" size="22" class="rightIcon"></u-icon>
				</view>
			</view>
			<view class="body">
				<view class="bodyItem">
					<view>生日：{{item.birthday}}</view>
					<view>到家日：{{item.arriveTime}}</view>
				</view>
				<view class="bodyItem">
					<view>是否开启驱虫提醒：</view>
					<!-- <u-switch v-model="" size="20" ></u-switch> -->
				</view>
				<view class="bodyItem">
					<view>是否开启疫苗提醒：</view>
					<!-- <u-switch v-model="" size="20" ></u-switch> -->
				</view>
			</view>
			<view class="foot">
				<view class="timeBox">它已陪伴你{{item.dayArrived}}天</view>
			</view>
		</uni-card>
	</view>
</template>

<script>
	import {getConstellation} from "@/utils/tools.js"
	
	export default {
		name:"pet-item",
		props: {
			item: {
				type: Object,
				default() {
					return {}
				}
			}
		},
		data() {
			return {
			};
		},
		methods: {
			jumpToDetail() {
				uni.navigateTo({
					url: '/pages/petDetail/petDetail'
				})
			}
		}
	}
</script>

<style lang="scss">
.petItem{
	position: relative;
	.head{
		display:flex;
		align-items: center;
		justify-content: space-between;
		.left {
			margin-top: 12rpx;
			display:flex;
			align-items: center;
			justify-content: space-between;
			.baseMsg {
				display: flex;
				flex-direction: column;
				margin-left: 24rpx;
				.firstLine {
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 36rpx;
					margin-top: 8rpx;
					font-family: '华文琥珀';
					.age {
						.petAge {
							height: 40rpx; 
							width: 110rpx; 
							display: flex; 
							align-items: center;
							justify-content: center;
							margin-left: 20rpx;
							font-size: 26rpx;
						}
					}
				}
				.kind{
					display:flex;
					font-size: 26rpx;
					margin-top: 20rpx;
				}
			}
		}
		.right {
			.rightIcon {
				position: absolute;
				right: 15rpx;
				top: 56rpx;
			}
		}
		
	}
	
	.body{
		margin-top: 12rpx;
		padding: 15rpx 0 15rpx;
		.bodyItem {
			display: flex;
			justify-content: space-between;
			padding-bottom: 12rpx;
		}
	}
	
	.foot {
		.timeBox {
			width: 100%;
			height: 60rpx;
			background-color: #f3f3f3;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 26rpx;
			border-radius: 0 0 10rpx 10rpx;
		}
	}
}
</style>